import { request } from "@/utils/http";
import type {
  findSourceListReturnType,
  getDepartmentReturnType,
  getHospitalListReturnType,
  getProvinceReqReturnType,
  getScheduleReturnType,
  hospitalDetailType,
  searchHospitalListParamsType,
} from "./model/hospitalListTypes";

export const getHospitalListRequest = (
  page: number,
  limit: number,
  search?: searchHospitalListParamsType
) => {
  return request.get<any, getHospitalListReturnType>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: search,
    }
  );
};

export const getProvinceListRequest = () => {
  return request.get<any, getProvinceReqReturnType>(
    "/admin/cmn/dict/findByDictCode/province"
  );
};

export const getCityDistrictListRequest = (value: string) => {
  return request.get<any, getProvinceReqReturnType>(
    `/admin/cmn/dict/findByParentId/${value}`
  );
};

export const changeHosStatusRequest = (id: string, status: 0 | 1) => {
  return request.get<any, null>(
    `/admin/hosp/hospital/updateStatus/${id}/${status}`
  );
};

export const getHospitalDetailRequest = (id: string) => {
  return request.get<any, hospitalDetailType>(
    `/admin/hosp/hospital/show/${id}`
  );
};

export const getDepartmentRequest = (hoscode: string) => {
  return request.get<any, getDepartmentReturnType>(
    `/admin/hosp/department/${hoscode}`
  );
};

export const getScheduleRuleRequest = (
  page: number,
  limit: number,
  hoscode: string,
  depcode: string
) => {
  return request.get<any, getScheduleReturnType>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
};

export const findSourceListRequest = (
  hoscode: string,
  depcode: string,
  workDate: string
) => {
  return request.get<any,findSourceListReturnType>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
};
